import logging
import os
from datetime import datetime

import ddddocr
import pytest
from tools.page import page_get

logger = logging.getLogger(__name__)


@pytest.fixture(scope="session", autouse=True)
def page_param():
    logger.info('开始启动浏览器')
    page = page_get()
    yield page
    page.quit()


@pytest.fixture(scope="function", params=[['15867710780', 'yexiong1997']])
def login_聚水潭(request, page_param):
    page = page_param
    page.get("https://www.erp321.com/epaas")
    page.wait(5)
    # 检查是否需要登录
    if page.s_ele('#side'):
        logger.info('登录信息有效,无需登录')
        return
    logger.info('登录信息失效,开始登录')
    page("#login_id").input(request.param[0], clear=True)
    page("#password").input(request.param[1], clear=True)
    page("#agreementCheck").click()
    page('立即登录').click()
    if page('注意：您的密码已经超过3个月未修改(304)，请您尽快修改密码！', timeout=3):
        page('确认').click()
    logger.info('登录成功')
    page.wait(5)

